<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
    <div id='app1'></div>
</body>
<script src="../js/task5.js">
    //使用“构造函数+prototype”的混合方式创建学员对象（年龄、姓名）

    //创建对象
    function person(name, age) {
        this.name = name
        this.age = age
    }
    //找原型对象
    let proto = person.prototype
    //给原型添加一个函数返回当前对象的属性
    proto.info = function () {
        return this.name + "-" + this.age
    }
    let p = new person("张小萌", 16)
    a = p.info()
    app.innerHTML = a
    //console.log(p.info())
    let p1 = new person("王思雨", 20)
    b = p1.info()
    app1.innerHTML = b
    //console.log(p1.info())
</script>

</html>